package com.example.sbbsec;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.sql.DataSource;

/**
 * Description: TODO
 *
 * @author Arat.Wu
 * @date 2019/02/15.
 */
@Configuration
public class SchedulerFactoryConfig {

    @Bean
    SchedulerFactoryBean schedulerFactoryBean(HikariDataSource dataSource){
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setDataSource(dataSource);
        schedulerFactoryBean.setAutoStartup(Boolean.TRUE);
        schedulerFactoryBean.setApplicationContextSchedulerContextKey("schedulerApplicationContextKey");
        Resource resource = new ClassPathResource("quartz.properties");
        schedulerFactoryBean.setConfigLocation(resource);
        return schedulerFactoryBean;
    }
}
